<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="dealerRuleDetail.heading"/></title>
    <meta name="menu" content="DealerRuleMenu"/>
    <meta name="heading" content="<fmt:message key='dealerRuleDetail.heading'/>"/>
</head>

<c:set var="delObject" scope="request"><fmt:message key="dealerRule.dealerRule"/></c:set>
<script type="text/javascript">var msgDelConfirm =
   "<fmt:message key="delete.confirm"><fmt:param value="${delObject}"/></fmt:message>";
</script>
<!-- Main content -->
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title"><fmt:message key="dealerRuleDetail.heading"/></h3>
                </div>
                <div class="box-body">
                <%@ include file="/common/messages.jsp" %>
                <form:errors path="dealerRule.*" cssClass="alert alert-danger alert-dismissable" element="div"/>
                <form:form commandName="dealerRule" method="post" action="dealerRuleForm"
                           id="dealerRuleForm" onsubmit="return validateDealerRule(this)">
                <div class="form-horizontal margin well">
                    <form:hidden path="id"/>
                    <form:hidden path="dealer.id"/>
                    <input hidden name="dealerId" value="${param.dealerId}"/>
                    <input type="hidden" name="from" value="<c:out value="${param.from}"/>"/>
                    <div class="form-group">
                        <spring:bind path="dealerRule.code">
                        <appfuse:label key="dealerRule.code" styleClass="control-label col-sm-1"/>
                        <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                            </spring:bind>
                            <form:input cssClass="form-control" path="code" id="code"  maxlength="4"/>
                            <form:errors path="code" cssClass="help-block"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <spring:bind path="dealerRule.description">
                        <appfuse:label key="dealerRule.description" styleClass="control-label col-sm-1"/>
                        <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                            </spring:bind>
                            <form:input cssClass="form-control" path="description" id="description"  maxlength="255"/>
                            <form:errors path="description" cssClass="help-block"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <spring:bind path="dealerRule.status">
                        <appfuse:label key="dealerRule.status" styleClass="control-label col-sm-1"/>
                        <div class="col-sm-3${(not empty status.errorMessage) ? ' has-error' : ''}">
                            </spring:bind>
                            <form:checkbox path="status" id="status" />
                            <form:errors path="status" cssClass="help-block"/>
                        </div>
                    </div>
                    <div id="actions" class="form-group">
                        <button type="submit" class="btn btn-primary" id="save" name="save" onclick="bCancel=false">
                            <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/>
                        </button>
                        <c:if test="${not empty dealerRule.id}">
                            <button type="submit" class="btn btn-danger" id="delete" name="delete" onclick="bCancel=true;return confirmMessage(msgDelConfirm)">
                                <i class="icon-trash icon-white"></i> <fmt:message key="button.delete"/>
                            </button>
                        </c:if>
                        <button type="submit" class="btn btn-default" id="cancel" name="cancel"
                                onclick="bCancel=true">
                            <i class="icon-remove"></i> <fmt:message key="button.cancel"/>
                        </button>
                    </div>
                </div>
                </form:form>
                </div>
            </div>
        </div>
    </div>

</section>

<v:javascript formName="dealerRuleForm" cdata="false" dynamicJavascript="true" staticJavascript="false"/>
<script type="text/javascript" src="<c:url value='/scripts/validator.jsp'/>"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $("input[type='text']:visible:enabled:first", document.forms['dealerRuleForm']).focus();
    });
</script>
